package git.determinal.template.view;




import java.util.Arrays;

public enum OrderType {
    ASC("ASC", "ASC", "升序"),
    DESC("DESC", "DESC", "不等于 ");

    private String value;
    private String alias;
    private String label;

    public String getValue() {
        return this.value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getAlias() {
        return this.alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public String getLabel() {
        return this.label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    private OrderType(String value, String alias, String label) {
        this.value = value;
        this.alias = alias;
        this.label = label;
    }

    public boolean equal(OrderType orderType) {
        return this.value.toUpperCase().equals(orderType.getValue().toUpperCase()) || this.alias.toUpperCase().equals(orderType.getAlias().toUpperCase());
    }

    public boolean equal(String orderType) {
        return this.value.toUpperCase().equals(orderType) || this.alias.toUpperCase().equals(orderType);
    }

    public static OrderType load(String value) {
        return value != null && !"".equals(value) ? (OrderType)Arrays.stream(values()).filter((enumObj) -> {
            return enumObj.getValue().toUpperCase().equals(value.toUpperCase()) || enumObj.getAlias().toUpperCase().equals(value.toUpperCase());
        }).findFirst().get() : ASC;
    }
}





